package com.zxq.web.controller;

import com.alibaba.fastjson.JSON;
import com.zxq.exchange.enums.EFrame;
import com.zxq.web.dto.PlatformCmdDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 产品配置信息里，接收设备上传信息
 */
@RestController("receiveCmd")
@Slf4j
public class IOTProductReceiveController {



    /**
     * 接收report消息
     * @param platformCmdDTO
     */
    @PostMapping("request")
    public PlatformCmdDTO requestReceive(@RequestBody PlatformCmdDTO platformCmdDTO) {
        log.info("receive:" + JSON.toJSONString(platformCmdDTO));
        PlatformCmdDTO result = new PlatformCmdDTO();
        BeanUtils.copyProperties(platformCmdDTO,result);
        String json = analyseMsg(platformCmdDTO.getFrameId(),platformCmdDTO.getCmdId(),platformCmdDTO.getJson());
        result.setJson(json);
        return result;
    }


    private String analyseMsg(Integer frameId, Long cmdId, String json) {
        EFrame tcpFrame = EFrame.getType(frameId);


        return null;
    }


}
